Regular octagon $ABCDEFGH$ has its center at $J$.  Each of the vertices and the center are to be associated with one of the digits $1$ through $9$, with each digit used once, in such a way that the sums of the numbers on the lines $AJE$, $BJF$, $CJG$, and $DJH$ are all equal.  In how many ways can this be done?
[asy]
pair A,B,C,D,E,F,G,H,J;
A=(20,20(2+sqrt(2)));
B=(20(1+sqrt(2)),20(2+sqrt(2)));
C=(20(2+sqrt(2)),20(1+sqrt(2)));
D=(20(2+sqrt(2)),20);
E=(20(1+sqrt(2)),0);
F=(20,0);
G=(0,20);
H=(0,20(1+sqrt(2)));
J=(10(2+sqrt(2)),10(2+sqrt(2)));
draw(A--B);
draw(B--C);
draw(C--D);
draw(D--E);
draw(E--F);
draw(F--G);
draw(G--H);
draw(H--A);
dot(A);
dot(B);
dot(C);
dot(D);
dot(E);
dot(F);
dot(G);
dot(H);
dot(J);
label("$A$",A,NNW);
label("$B$",B,NNE);
label("$C$",C,ENE);
label("$D$",D,ESE);
label("$E$",E,SSE);
label("$F$",F,SSW);
label("$G$",G,WSW);
label("$H$",H,WNW);
label("$J$",J,SE);
size(4cm);
[/asy]
Explanation: Let $x$ denote the common sum of the numbers on each line. Then $4x$ gives the sum of all the numbers $A, B, \ldots, J,$ but with $J$ counted four times. Since the sum of the numbers on the octagon must be $1 + 2 + \dots + 9 = 45,$ we have $4x = 45 + 3J$ (where $J$ represents the number written at that vertex). Thus, $45 + 3J$ must be a multiple of $4$, which occurs exactly when $J \in \{1, 5, 9\}.$

If $J = 1,$ then $4x = 45 + 3J = 48,$ so $x = 12.$ It follows that the sum of each pair of diametrically opposite vertices is $12 - 1 = 11,$ so we must pair up the numbers $\{2, 9\}$, $\{3, 8\}$, $\{4, 7\}$, and $\{5, 6\}.$ There are $4!$ ways to assign the four pairs, and then $2^4$ ways to assign the two numbers in each individual pair. Therefore, in the case $J = 1$, there are $4! \cdot 2^4 = 384$ ways to label the vertices.

The cases $J = 5$ and $J = 9$ are the same, and also produce $384$ valid ways. Thus, the total number of ways to label the vertices is $3 \cdot 384 = \boxed{1152}.$